<template>
  <el-dialog v-if="data" title="用户" :visible="true">
    <el-form
      ref="dataForm"
      :rules="rules"
      :model="data"
      label-position="left"
      label-width="70px"
      style="width: 400px; margin-left:50px;"
    >
      <el-form-item :label="$t('table.username')" prop="username">
        <el-input v-model="data.username" />
      </el-form-item>
      <el-form-item v-if="dialogStatus!='create'">
        <el-switch
          v-model="editPassword"
          active-text="修改密码"
          >
        </el-switch>
      </el-form-item>
      <el-form-item :label="$t('table.password')" prop="password" v-if="editPassword||dialogStatus=='create'">
        <el-input v-model="data.password" />
      </el-form-item>
      <el-form-item :label="$t('table.avatarFileId')" prop="avatarFileId">
        <el-upload
          :action="uploadUrl"
          :headers="{
            'authorization': token
          }"
          list-type="picture-card"
          :show-file-list="false"
          accept=".jpg,.png,.gif,.jpeg"
          :on-success="onUploadSuccess"
          :on-error="onUploadError"
        >
          <img v-if="data.coverFile" :src="data.coverFile.url">
          <i v-else class="el-icon-plus" />
        </el-upload>
      </el-form-item>
      <el-form-item :label="$t('table.status')" prop="status">
        <el-select v-model="data.status" class="filter-item" placeholder="Please select">
          <el-option v-for="item in calendarTypeOptions" :key="item.key" :label="item.display_name" :value="item.key" />
        </el-select>
      </el-form-item>
    </el-form>
    <div slot="footer" class="dialog-footer">
      <el-button @click="dialogFormVisible = false">
        {{ $t('table.cancel') }}
      </el-button>
      <el-button type="primary" @click="dialogStatus === 'create' ? createData() : updateData()">
        {{ $t('table.confirm') }}
      </el-button>
    </div>
  </el-dialog>
</template>

<script>
export default {
  name: '',
  props: ['data'],
  data() {
    return
  },
  methods: {
  }
}
</script>

<style lang="scss">
</style>
